#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[])
{
	int t, n, mi;
	const int MaximumNumberOfDevices = 100;
	const int MaximumNumberOfManufacturers = 100;
	int MaximumBandWidth = 0;
	int devices[MaximumNumberOfDevices];
	int manufacturers[MaximumNumberOfDevices][MaximumNumberOfManufacturers << 1];
		
	cin >> t;
	for (int j = 0; j < t; j++) {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> mi;
			devices[i] = mi;
			for (int k = 0; k < mi; k++) {
				int bandwidth, price;
				cin >> bandwidth >> price;
				manufacturers[i][k << 1] = bandwidth;
				manufacturers[i][(k << 1) + 1] = price;
				if (MaximumBandWidth < bandwidth) {
					MaximumBandWidth = bandwidth;
				}
			}
		}

		int **pricesMatrix = new int* [n + 1];
		for (int i = 0; i < n + 1; i++) {
			pricesMatrix[i] = new int[MaximumBandWidth + 1];
		}

		for (int i = 0; i < n + 1; i++) {
			for (int j = 0; j < MaximumBandWidth + 1; j++) {
				if (i == 0)
					pricesMatrix[i][j] = 0;
				else 
					pricesMatrix[i][j] = -1;
			}
		}

		for (int i = 1; i < n + 1; i++) {
			for (int j = 0; j < MaximumBandWidth + 1; j++) {
				bool isMaximal = true;
				for (int k = 0; k < devices[i - 1]; k++) {
					int bw = manufacturers[i - 1][k << 1];
					int pr = manufacturers[i - 1][(k << 1) + 1];
					if (bw >= j)
						isMaximal = false;
					//if (bw >= j && pricesMatrix[i][j] == -1) {
					//	pricesMatrix[i][j] = pricesMatrix[i - 1][j] + pr;
					//} else if (bw >= j) {
					//	if (pricesMatrix[i][j] > (pricesMatrix[i - 1][j] + pr)) {
					//		pricesMatrix[i][j] = pricesMatrix[i - 1][j] + pr;
					//	}
					//}
					int minor = min(bw, j);
					if (pricesMatrix[i][minor] == -1 && pricesMatrix[i - 1][minor] != -1) {
						pricesMatrix[i][minor] = pricesMatrix[i - 1][minor] + pr;
					} else if (pricesMatrix[i][minor] > pricesMatrix[i - 1][minor] + pr){
						pricesMatrix[i][minor] = pricesMatrix[i - 1][minor] + pr;
					}
				}

				if (isMaximal){
					pricesMatrix[i][j] = -1;
					break;
				}
			}
		}

		double m = 0.0;
		for (int j = 1; j < MaximumBandWidth + 1; j++) {
			if (m < j * 1.0 / pricesMatrix[n][j]) {
				m = j * 1.0 / pricesMatrix[n][j];
			}
		}

		printf("%.3lf\n", m);


		for (int i = 0; i < n + 1; i++) {
			delete[] pricesMatrix[i];
		}

		delete[] pricesMatrix;
	}

	

	return 0;
}
